<template>
    <view class="container">
        <view class="title">
            <view>{{ newsinfo.title }}</view>
            <view>{{ newsinfo.createtime }}</view>
        </view>
        <view class="content">
            <rich-text :nodes="content"></rich-text>
        </view>
    </view>
</template>

<script>
import { Notice } from '../../model/notice-model.js';
var notice = new Notice();
export default {
    data() {
        return {
            id: 0,
            content: '',

            newsinfo: {
                title: '',
                createtime: ''
            }
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: function (e) {
        var that = this;
        if (that.id > 0) {
            var id = that.id;
        } else {
            var id = e.id;
            that.id = e.id;
        }
        var params = {
            id: that.id
        };
        notice.GetNoticedetail((data) => {
            uni.setNavigationBarTitle({
                title: data.noticeinfo.title
            });
            let content = data.noticeinfo.content
                .replace(/<p([\s\w"=\/\.:;]+)((?:(style="[^"]+")))/gi, '<p')
                .replace(/<p>/gi, '<p style="font-size: 15Px; line-height: 25Px;">')
                .replace(/<img([\s\w"-=\/\.:;]+)((?:(height="[^"]+")))/gi, '<img$1')
                .replace(/<img([\s\w"-=\/\.:;]+)((?:(width="[^"]+")))/gi, '<img$1')
                .replace(/<img([\s\w"-=\/\.:;]+)((?:(style="[^"]+")))/gi, '<img$1')
                .replace(/<img([\s\w"-=\/\.:;]+)((?:(alt="[^"]+")))/gi, '<img$1')
                .replace(/<img([\s\w"-=\/\.:;]+)/gi, '<img$1 style="width: 100%;"');
            that.setData({
                content: content,
                newsinfo: data.noticeinfo
            });
        }, params);
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {},
    methods: {}
};
</script>
<style>
.container {
    background-color: #fff;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}
.container .title {
    display: flex;
    flex-direction: column;
    width: 100%;
    border-bottom: 1px dotted #ccc;
}
.container .title view {
}
.container .title view:nth-child(1) {
    font-size: 0.9rem;
    font-weight: bold;
    padding-left: 10rpx;
    padding-top: 10rpx;
    padding-bottom: 10rpx;
}
.container .title view:nth-child(2) {
    font-size: 0.6rem;
    padding-left: 10rpx;
    padding-bottom: 10rpx;
}
.container .content {
    padding: 20rpx;
    font-size: 0.8rem;
    word-spacing: 15rpx;
}

.container .content image {
}
</style>
